import util from './util'

/**
 * 获取当前用户的菜单列表
 * @link http://10.20.5.146:9010/swagger-ui.html
 */
async function userOwnList() {
    let userOwnList = await util.ajax
        .get('/menu/user-own/list')
        .then(res => {
            return res
        })
        .catch(error => {
            return Promise.reject(error)
        })

    return userOwnList
}
/**
 * 新增菜单
 */
async function addMenu() {
    let addMenu = await util.ajax
        .post('/menu')
        .then(res => {
            return res
        })
        .catch(error => {
            return Promise.reject(error)
        })
}
/**
 * 删除菜单
 */
async function deletMenu(params) {
    let deletMenu = await util.ajax
        .delete(`/menu/${params.id}`)
        .then(res => {
            return res
        })
        .catch(error => {
            return Promise.reject(error)
        })
}
/**
 * 修改菜单
 */
async function modifyMenu(params) {
    let modifyMenu = await util.ajax
        .put(`/menu/${params.id}`)
        .then(res => {
            return res
        })
        .catch(error => {
            return Promise.reject(error)
        })
}
/**
 * 菜单查询
 */
async function queryMenu(params) {
    let queryMenu = await util.ajax
        .get('/menu', {params})
        .then(res => {
            return res
        })
        .catch(error => {
            return Promise.reject(error)
        })
}
export default {
    addMenu,
    deletMenu,
    modifyMenu,
    queryMenu,
    userOwnList,
}
